<template>
    <div class="edu-page-warp">
        <InnerBreadcrumb v-model="indexKey" :path="breadPath" :showBack="true" />
        <div v-show="indexKey == '0'">
            <condition-card @reset="reset" @search="onSubmit" label-width="110px">
                <el-row :gutter="24">
                    <el-col :span="8">
                        <el-form-item :label="$t('label.grade')">
                            <el-date-picker
                                clearable
                                v-model="queryForm.grade"
                                value-format="yyyy"
                                type="year"
                                :placeholder="$t('message.plzSelect')"
                                style="width: 100%"
                            />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('label.college')">
                            <el-select
                                v-model="queryForm.faculty"
                                filterable
                                style="width:100%"
                                clearable
                                @change="handleChangeFaculty"
                                multiple
                                collapse-tags
                            >
                                <el-option
                                    v-for="item in options.faculty"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('label.major')">
                            <el-select
                                v-model="queryForm.profession"
                                filterable
                                style="width:100%;height:33px"
                                clearable
                                multiple
                                collapse-tags
                            >
                                <el-option
                                    v-for="item in options.profession"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="24">
                    <el-col :span="8">
                        <el-form-item :label="$t('dic.degreeType')">
                            <el-select
                                v-model="queryForm.degreeType"
                                style="width:100%"
                                clearable
                                @change="handleChangeFaculty"
                            >
                                <el-option
                                    v-for="item in options.degreeType"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <!-- <el-col :span="8">
                        <el-form-item :label="$t('label.trainingLevel')">
                            <el-select
                                v-model="queryForm.trainingLevel"
                                style="width:100%"
                                clearable
                            >
                                <el-option
                                    v-for="item in options.trainingLevel"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('label.trainingCategory')">
                            <el-select
                                v-model="queryForm.trainingCategory"
                                style="width:100%"
                                clearable
                            >
                                <el-option
                                    v-for="item in options.trainingCategory"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    
                    <el-col :span="8">
                        <el-form-item :label="$t('label.formLearning')">
                            <el-select
                                v-model="queryForm.formLearning"
                                style="width:100%"
                                clearable
                            >
                                <el-option
                                    v-for="item in options.formLearning"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('label.enrolMethod')">
                            <el-select
                                v-model="queryForm.enrolMethodList"
                                style="width:100%"
                                multiple
                                collapse-tags
                                clearable
                            >
                                <el-option
                                    v-for="item in options.enrolMethods"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col> -->
                     <el-col :span="8">
                        <el-form-item label="审核状态">
                            <el-select
                                filterable
                                style="width:100%;height:33px"
                                clearable
                                v-model="queryForm.approvalStatus"
                                multiple
                                collapse-tags
                            >
                                <el-option
                                    v-for="item in options.approvalStatus"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="申请类型">
                            <el-select
                                filterable
                                style="width:100%"
                                clearable
                                v-model="queryForm.permitType"
                            >
                                <el-option
                                    v-for="item in options.permitType"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="24">
                    <el-col :span="8">
                        <el-form-item label="申请原因">
                            <el-select
                                filterable
                                style="width:100%;height:33px"
                                clearable
                                v-model="queryForm.applyReason"
                                multiple
                                collapse-tags
                            >
                                <el-option
                                    v-for="item in options.applyReason"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="申请开始时间">
                            <el-date-picker
                                v-model="queryForm.applicationStartTime"
                                clearable
                                value-format="yyyy-MM-dd HH:mm:ss"
                                type="datetime"
                                :placeholder="$t('common.text.all')"
                                style="width: 100%"
                            />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="申请结束时间">
                            <el-date-picker
                                v-model="queryForm.applicationEndTime"
                                clearable
                                value-format="yyyy-MM-dd HH:mm:ss"
                                type="datetime"
                                :placeholder="$t('common.text.all')"
                                style="width: 100%"
                            />
                        </el-form-item>
                    </el-col>
                </el-row>
            </condition-card>
            <el-card shadow="never">
                <div class="edu-page-title">博转硕代申请列表</div>
                <el-row>
                    <el-col :span="4">
                        <el-input
                            v-model="queryForm.keyWord"
                            :placeholder="$t('score.failScoreManage.pleaseInt')"
                            @keyup.enter.native="onSubmit"
                            style="width:200px"
                        >
                            <i
                                class="el-icon-search"
                                slot="suffix"
                                style="margin-top:10px;cursor:pointer"
                                @click="onSubmit"
                            ></i>
                        </el-input>
                    </el-col>
                    <div class="float-right" style="display: flex">
                    <!-- 新增 -->
                    <el-button type="primary" @click="handleAgentApply()">新增</el-button>
                </div>
                </el-row>
                
                <edu-table
                    :data="students"
                    size="mini"
                    :order="false"
                    :selection="false"
                    style="width:100%;margin-top:12px"
                    @page-change="handleCurrentChange"
                    :total="queryForm.total_"
                    :pageSize="queryForm.pageSize_"
                    :pageNum="queryForm.pageNum_"
                >
                    <!-- <el-table-column
                        :label="$t('label.stuCode')"
                        prop="studentId"
                        show-overflow-tooltip
                        width="80"
                    ></el-table-column>
                    <el-table-column
                        :label="$t('label.stuName')"
                        prop="name"
                        width="80"
                        show-overflow-tooltip
                    ></el-table-column>
                    <el-table-column :label="$t('label.grade')" prop="grade" width="60"></el-table-column>
                    <el-table-column :label="$t('label.college')" show-overflow-tooltip width="100">
                        <template slot-scope="scope">{{ scope.row.facultyI18n }}</template>
                    </el-table-column>
                    <el-table-column :label="$t('label.major')" show-overflow-tooltip width="100">
                        <template slot-scope="scope">{{ scope.row.professionI18n }}</template>
                    </el-table-column>
                    <el-table-column :label="$t('label.trainingLevel')">
                        <template slot-scope="scope">{{ scope.row.trainingLevelI18n }}</template>
                    </el-table-column>
                    <el-table-column :label="$t('label.trainingCategory')" width="100">
                        <template slot-scope="scope">{{ scope.row.trainingCategoryI18n }}</template>
                    </el-table-column>
                    <el-table-column :label="$t('dic.degreeType')" prop="degreeType">
                        <template slot-scope="scope">{{ scope.row.degreeTypeI18n }}</template>
                    </el-table-column>
                    <el-table-column :label="$t('label.formLearning')">
                        <template slot-scope="scope">{{ scope.row.formLearningI18n }}</template>
                    </el-table-column>
                    <el-table-column :label="$t('label.enrolMethod')">
                        <template slot-scope="scope">{{ scope.row.enrolMethodsI18n }}</template>
                    </el-table-column>
                    <el-table-column label="导师" width="120" show-overflow-tooltip>
                        <template slot-scope="scope">
                            <span
                                v-if="scope.row.teacherId"
                            >{{ scope.row.teacherName }}({{scope.row.teacherId}})</span>
                        </template>
                    </el-table-column> -->
                    <!-- <el-table-column :label="$t('message.operating')" width="60">
                        <template slot-scope="scope">
                            <el-button
                                type="text"
                                @click=" handleAgentApply(scope.row) "
                            >{{$t('message.apply')}}</el-button>
                        </template>
                    </el-table-column> -->
                    <el-table-column :label="$t('label.stuCode')" fixed="left" prop="studentId" />
                    <el-table-column :label="$t('label.stuName')" fixed="left" prop="name" />
                    <el-table-column :label="$t('label.grade')" prop="grade" />
                    <el-table-column
                        :label="$t('label.college')"
                        width="120"
                        prop="facultyI18n"
                        show-overflow-tooltip
                    />
                    <el-table-column
                        :label="$t('label.major')"
                        width="120"
                        prop="professionI18n"
                        show-overflow-tooltip
                    />
                    <el-table-column label="申请类型" prop="permitTypeI18n" show-overflow-tooltip />
                    <el-table-column :label="$t('dic.degreeType')" prop="degreeTypeI18n" />
                    <el-table-column :label="$t('label.formLearning')" prop="formLearningI18n" />
                    <el-table-column label="导师" width="140">
                        <template slot-scope="scope">
                            <span
                                v-if="scope.row.teacherId"
                            >{{scope.row.teacherName}}({{scope.row.teacherId}})</span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        label="申请原因"
                        width="120"
                        show-overflow-tooltip
                        prop="applyReasonI18n"
                    />
                    <el-table-column label="申请时间" width="160" show-overflow-tooltip>
                        <template slot-scope="scope">{{moment(scope.row.applicationTime)}}</template>
                    </el-table-column>
                    <el-table-column :label="$t('courseSummary.aduitType')">
                        <template slot-scope="scope">{{getApproveText(scope)}}</template>
                    </el-table-column>
                    <el-table-column label="当前处理人" width="160" show-overflow-tooltip>
                        <template slot-scope="scope">
                            <el-button
                                type="text"
                                v-if="scope.row.approvalStatus>=5 && scope.row.reviewerName"
                                @click="handleReviewGroup(scope.row.reviewer)"
                            >{{scope.row.reviewerName}}({{scope.row.reviewer}})</el-button>
                            <!--导师-->
                            <span
                                v-else-if="scope.row.approvalStatus==4 && scope.row.reviewerName"
                            >{{scope.row.reviewerName}}({{scope.row.reviewer}})</span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        :label="$t('message.operating')"
                        fixed="right"
                        :width="oprWidth"
                    >
                        <template slot-scope="scope">
                            <el-button
                                type="text"
                                @click="handleDetail(scope)"
                            >{{$t('message.detail')}}</el-button>
                        </template>
                    </el-table-column>
                </edu-table>
            </el-card>
        </div>
        <div v-show="indexKey == '1'">
            <el-card shadow="never">
                <div v-if="!isSingleStudent">
                    <div class="edu-page-title">学生信息</div>
                    <hr style="margin:10px 0" />
                    <el-form
                        label-position="right"
                        label-width="150px"
                        label-suffix="："
                        id="stu-info"
                        @submit.native.prevent
                    >
                         
                            <el-row :gutter="24">
                            <el-col :span="6">
                                <!-- <el-form-item
                                    :label="$t('label.stuCode')"
                                >{{selectedStudents[0].studentId}}</el-form-item> -->
                                <el-form-item
                                    :label="$t('label.stuCode')"
                                >
                                <el-input
                                    v-model="searchStudentId"
                                    @blur="getOneStu"
                                    style="width:200px"
                                    @keyup.enter.native="getOneStu"
                                >
                                    <i
                                        class="el-icon-search"
                                        slot="suffix"
                                        style="cursor:pointer"
                                        @click="getOneStu"
                                    ></i>
                                </el-input>
                                 </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item
                                    :label="$t('label.stuName')"
                                >{{selectedStudents[0].name}}</el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item
                                    :label="$t('label.college')"
                                >{{selectedStudents[0].facultyI18n}}</el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item
                                    :label="$t('label.major')"
                                >{{selectedStudents[0].professionI18n}}</el-form-item>
                            </el-col>
                            </el-row>
                            <el-row :gutter="24">
                            <el-col :span="6">
                                <el-form-item
                                    :label="$t('label.grade')"
                                >{{selectedStudents[0].grade}}</el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="导师">
                                    <span
                                        v-if="selectedStudents[0].teacherId"
                                    >{{selectedStudents[0].teacherName}}({{selectedStudents[0].teacherId}})</span>
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item
                                    :label="$t('label.trainingLevel')"
                                >{{selectedStudents[0].trainingLevelI18n}}</el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item
                                    :label="$t('label.trainingCategory')"
                                >{{selectedStudents[0].trainingCategoryI18n}}</el-form-item>
                            </el-col>
                            </el-row>
                            <el-row :gutter="24">

                            <el-col :span="6">
                                <el-form-item
                                    :label="$t('dic.degreeType')"
                                >{{selectedStudents[0].degreeTypeI18n}}</el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item
                                    :label="$t('label.formLearning')"
                                >{{selectedStudents[0].formLearningI18n}}</el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item
                                    :label="$t('label.enrolMethod')"
                                >{{selectedStudents[0].enrolMethodsI18n}}</el-form-item>
                            </el-col>
                        </el-row>
                    </el-form>
                </div>
                <div v-if="isSingleStudent">
                    <div class="edu-page-title">已选择学生</div>
                    <edu-table
                        :data="selectedStudents"
                        :selection="false"
                        :order="false"
                        :pagination="false"
                        style="margin:10px 0 15px"
                    >
                        <el-table-column
                            :label="$t('label.stuCode')"
                            prop="studentId"
                            show-overflow-tooltip
                            width="80"
                        ></el-table-column>
                        <el-table-column
                            :label="$t('label.stuName')"
                            prop="name"
                            width="80"
                            show-overflow-tooltip
                        ></el-table-column>
                        <el-table-column :label="$t('label.grade')" prop="grade" width="80"></el-table-column>
                        <el-table-column
                            :label="$t('label.college')"
                            show-overflow-tooltip
                            width="100"
                        >
                            <template slot-scope="scope">{{ scope.row.facultyI18n }}</template>
                        </el-table-column>
                        <el-table-column
                            :label="$t('label.major')"
                            show-overflow-tooltip
                            width="100"
                        >
                            <template slot-scope="scope">{{ scope.row.professionI18n }}</template>
                        </el-table-column>
                        <el-table-column :label="$t('label.trainingLevel')">
                            <template slot-scope="scope">{{ scope.row.trainingLevelI18n }}</template>
                        </el-table-column>
                        <el-table-column :label="$t('label.trainingCategory')">
                            <template slot-scope="scope">{{ scope.row.trainingCategoryI18n }}</template>
                        </el-table-column>
                        <el-table-column :label="$t('dic.degreeType')" prop="degreeType">
                            <template slot-scope="scope">{{ scope.row.degreeTypeI18n }}</template>
                        </el-table-column>
                        <el-table-column :label="$t('label.formLearning')">
                            <template slot-scope="scope">{{ scope.row.formLearningI18n }}</template>
                        </el-table-column>
                        <el-table-column :label="$t('label.enrolMethod')">
                            <template slot-scope="scope">{{ scope.row.enrolMethodsI18n }}</template>
                        </el-table-column>
                        <el-table-column label="导师" show-overflow-tooltip>
                            <template slot-scope="scope">
                                <span
                                    v-if="scope.row.teacherId"
                                >{{ scope.row.teacherName }}({{scope.row.teacherId}})</span>
                            </template>
                        </el-table-column>
                    </edu-table>
                </div>
            </el-card>
            <apply-form
                ref="applyForm"
                :options="options"
                :students="this.selectedStudents"
                :type='this.type'
                :submissionType="submissionType"
                pageFrom="apply"
                :show-please-num="showPleaseNum"
                @close="handleReturn"
                @success="handleSuccess"
            />
        </div>
        <div v-show="indexKey == '2'">
            <el-card shadow="never">
                <div v-if="currentStudent">
                    <div class="edu-page-title">学生信息</div>
                    <hr style="margin:15px 0 10px 0" />
                    <el-form
                        label-position="right"
                        label-width="150px"
                        label-suffix="："
                        id="stu-info"
                    >
                        <el-row>
                            <el-col :span="colSpan">
                                <el-form-item
                                    :label="$t('label.stuCode')"
                                >{{currentStudent.studentId}}</el-form-item>
                            </el-col>
                            <el-col :span="colSpan">
                                <el-form-item :label="$t('label.stuName')">{{currentStudent.name}}</el-form-item>
                            </el-col>
                            <el-col :span="colSpan">
                                <el-form-item
                                    :label="$t('label.college')"
                                >{{currentStudent.facultyI18n}}</el-form-item>
                            </el-col>
                            <el-col :span="colSpan">
                                <el-form-item
                                    :label="$t('label.major')"
                                >{{currentStudent.professionI18n}}</el-form-item>
                            </el-col>

                            <el-col :span="colSpan">
                                <el-form-item :label="$t('label.grade')">{{currentStudent.grade}}</el-form-item>
                            </el-col>
                            <el-col :span="colSpan">
                                <el-form-item label="导师">
                                    <span
                                        v-if="currentStudent.teacherId"
                                    >{{currentStudent.teacherName}}({{currentStudent.teacherId}})</span>
                                </el-form-item>
                            </el-col>
                            <el-col :span="colSpan">
                                <el-form-item
                                    :label="$t('label.trainingLevel')"
                                >{{currentStudent.trainingLevelI18n}}</el-form-item>
                            </el-col>
                            <el-col :span="colSpan">
                                <el-form-item label="申请类型">{{currentStudent.permitTypeI18n}}</el-form-item>
                            </el-col>

                            <el-col :span="colSpan">
                                <el-form-item
                                    :label="$t('dic.degreeType')"
                                >{{currentStudent.degreeTypeI18n}}</el-form-item>
                            </el-col>
                            <el-col :span="colSpan">
                                <el-form-item
                                    :label="$t('label.formLearning')"
                                >{{currentStudent.formLearningI18n}}</el-form-item>
                            </el-col>
                        </el-row>
                    </el-form>
                </div>
                <hr style="margin:0 0 15px 0" />
                <!--详情-->
                <div v-if="isRead">
                    <div class="edu-page-title">申请明细</div>
                    <table class="table-detail">
                        <col width="15%" />
                        <col width="35%" />
                        <col width="15%" />
                        <col width="35%" />
                        <tr>
                            <td class="label">
                                <span>申请原因：</span>
                            </td>
                            <td colspan="3">
                                <span>{{currentStudent.applyReasonI18n}}</span>
                            </td>
                        </tr>
                        <tr>
                            <td class="label">
                                <span>请示文号：</span>
                            </td>
                            <td>
                                <span>{{currentStudent.pleaseNum}}</span>
                            </td>
                            <td class="label">
                                <span>发文编号：</span>
                            </td>
                            <td>
                                <span>{{currentStudent.issueNum}}</span>
                            </td>
                        </tr>
                        <tr>
                            <td class="label">
                                <span>硕士专业：</span>
                            </td>
                            <td>
                                <span>{{currentStudent.masProfessionI18n}}({{currentStudent.masProfession}})</span>
                            </td>
                            <td class="label">
                                <span>硕士导师：</span>
                            </td>
                            <td>
                                <span
                                    v-if="currentStudent.masTeacherId"
                                >{{currentStudent.masTeacherName}}({{currentStudent.masTeacherId}})</span>
                            </td>
                        </tr>
                        <tr>
                            <td class="label">
                                <span>硕士培养层次：</span>
                            </td>
                            <td>
                                <span>{{currentStudent.masTrainingLevelI18n}}</span>
                            </td>
                            <td class="label">
                                <span>硕士培养类别：</span>
                            </td>
                            <td>
                                <span
                                >{{currentStudent.masTrainingCategoryI18n}}</span>
                            </td>
                        </tr>
                        <tr>
                            <td class="label">
                                <span>硕士学位类型：</span>
                            </td>
                            <td colspan="3">
                                <span>{{currentStudent.masDegreeTypeI18n}}</span>
                            </td>
                        </tr>
                        <tr>
                            <td class="label">
                                <span>硕士年级：</span>
                            </td>
                            <td>
                                <span>{{currentStudent.masGrade}}</span>
                            </td>
                            <td class="label">
                                <span>入学季节：</span>
                            </td>
                            <td>
                                <span>{{currentStudent.masEnrolSeasonI18n}}</span>
                            </td>
                        </tr>
                        <tr>
                            <td class="label">
                                <span>博转硕开始时间：</span>
                            </td>
                            <td>
                                <span>{{currentStudent.masStartTime}}</span>
                            </td>
                            <td class="label">
                                <span>硕士阶段最晚结束时间：</span>
                            </td>
                            <td>
                                <span>{{currentStudent.masEndTime}}</span>
                            </td>
                        </tr>
                        <tr>
                            <td class="label">
                                <span>原因说明：</span>
                            </td>
                            <td colspan="3">
                                <span>{{currentStudent.reasonDescri}}</span>
                            </td>
                        </tr>
                        <tr>
                            <td class="label">
                                <span>申请材料：</span>
                            </td>
                            <td colspan="3">
                                <!-- <div :key="index" v-for="(file,index) in currentStudent.evidence">
                                    <span>
                                        <a
                                            href="#"
                                            @click="handleDownLoad(file)"
                                        >{{getFileName(file.name)}}</a>
                                    </span>
                                </div> -->
                                <PreviewOffice
                                :newFileList="currentStudent.evidence"
                                />
                            </td>
                        </tr>
                    </table>
                </div>
            </el-card>
            <el-card shadow="never" v-if="currentStudent&&currentStudent.workflowNo">
                <div class="edu-page-title">审批进度</div>
                <edu-table
                    key="prograss"
                    :pagination="false"
                    style="margin-top:10px"
                    :selection="false"
                    :data="historys"
                    :order="false"
                >
                    <el-table-column :label="$t('message.order')" prop="order_" width="50" />
                    <el-table-column :label="$t('message.time')" prop="approvalTime">
                        <template slot-scope="scope">{{ moment(scope.row.approvalTime)}}</template>
                    </el-table-column>
                    <el-table-column label="审批人">
                        <template
                            slot-scope="scope"
                        >{{scope.row.reviewerName}}({{scope.row.reviewer}})</template>
                    </el-table-column>
                    <el-table-column :label="$t('label.operation')" prop="processOperat" />
                    <el-table-column label="节点" prop="processNodes" />
                    <el-table-column label="说明" prop="reasonDescri" show-overflow-tooltip />
                </edu-table>
            </el-card>
        </div>
        <edu-dialog
            title="组内用户明细"
            ref="groupUsers"
            width="800px"
            @close="handleGroupUsersClose"
            :showFooter="false"
        >
            <edu-table
                key="users"
                :data="users"
                size="mini"
                style="width:100%"
                @page-change="handleUserCurrentChange"
                :total="usersQueryForm.total_"
                :pageSize="usersQueryForm.pageSize_"
                :pageNum="usersQueryForm.pageNum_"
                :selection="false"
            >
                <el-table-column label="账号" prop="studentId" width="100"></el-table-column>
                <el-table-column label="用户名" prop="name" width="100"></el-table-column>
                <el-table-column label="联系电话" prop="phoneNumber" show-overflow-tooltip></el-table-column>
                <el-table-column label="联系邮箱" prop="email" show-overflow-tooltip></el-table-column>
                <el-table-column label="类型" width="80">
                    <template slot-scope="scope">{{getUserType(scope.row.userType)}}</template>
                </el-table-column>
            </edu-table>
        </edu-dialog>
    </div>
</template>
<script>
import { queryDic } from "common/src/api/dictionary";
import {
    getStudentInfo,
    getRepStuAppList,
    approvalHistory,
    getStuTeas,
    getmanageList,
    getGraduateDegreeByColleges
} from "common/src/api/culture/change";
import { downloadfile } from "common/src/api/upload";
import stu from 'common/src/api/studentinfo'
import ApplyForm from "./ApplyForm";
import { getUserInfoListByGroupId } from "common/src/api/user";
import PreviewOffice from "common/src/components/common/PreviewOffice.vue"
import mixin from 'common/src/mixins/index';
export default {
    name: "AgentApply",
    mixins: [mixin],
    props: {
        type: {
            default: null,
            required: true
        },
        submissionType: {
            default: null,
            required: true
        }
    },
    components: {
        ApplyForm,
        PreviewOffice
    },
    data: function() {
        return {
            queryForm: {
                grade: null,
                submissionType: '',
                faculty: null,
                profession: null,
                // trainingLevel: null,
                // trainingCategory: null,
                degreeType: null,
                // formLearning: null,
                showSubmit: true,
                // enrolMethodList: [],
                applyReason: [],
                approvalStatus: [],
                permitType: null,
                applicationStartTime: null,
                applicationEndTime: null,
                keyWord: null,
                pageSize_: 20,
                pageNum_: 1,
                total_: 0
            },
            users: null,
            usersQueryForm: {
                groupId: null,
                pageSize_: 20,
                pageNum_: 1,
                total_: 0
            },
            options: {
                faculty: [],
                profession: [],
                trainingLevel: [],
                trainingCategory: [],
                degreeType: [],
                formLearning: [],
                enrolMethods: [],
                applyReason: [],
                enrolSeason: [],
                masProfessions: [],
                masTeachers: [],
                permitType: [],
                approvalStatus: [
                    {
                    label: "草稿",
                    value: "0"  
                    },
                    {
                    label: "审核中",
                    value: "1"
                    },
                    {
                    label: "驳回",
                    value: "2"
                    },
                    {
                    label: "通过",
                    value: "3"
                    },
                    {
                    label: "导师审核",
                    value: "4"
                    },
                    {
                    label: "学院审核",
                    value: "5"
                    },
                    {
                    label: "留办审核",
                    value: "6"
                    },
                    {
                    label: "培养处审核",
                    value: "7"
                    },
                    {
                    label: "管理处审核",
                     value: "8"
                    } 
                ]
            },
            historys: [],
            students: null,
            searchStudentId: '',
            indexKey: "0",
            breadPath: {
                label: "博转硕",
                key: "0",
                children: [
                    {
                        key: "1",
                        label:
                            this.type == "1" ? "管理员代申请" : "教务员代申请"
                    },
                    {
                        key: "2",
                        label: ''
                    }
                ]
            },
            selectedStudents: [
                {
                    name:'',
                    facultyI18n: '',
                    professionI18n: '',
                    grade: '',
                    teacherName:'',
                    teacherId: '',
                    trainingLevelI18n: '',
                    degreeType: '',
                    trainingCategoryI18n: '',
                    degreeTypeI18n: '',
                    formLearningI18n: '',
                    enrolMethodsI18n: '',
                }
            ],
            showPleaseNum: false
        };
    },
    computed: {
        isSingleStudent: function() {
            return this.selectedStudents && this.selectedStudents.length > 1
                ? true
                : false;
        },
        colSpan() {
            if (
                this.selectedStudents == [] ||
                this.selectedStudents.length != 1
            ) {
                return 6;
            }

            if (
                this.selectedStudents[0].facultyI18n &&
                this.selectedStudents[0].facultyI18n.length >= 8
            ) {
                return 8;
            }
            if (
                this.selectedStudents[0].professionI18n &&
                this.selectedStudents[0].professionI18n.length >= 8
            ) {
                return 8;
            }
            return 6;
        }
    },
    mounted() {
        this.init();
        if (this.global.isAdmin || this.global.isAcdemicDean) {
            this.showPleaseNum = true;
        }
    },
    methods: {
        init() {
            const data = {
                lang: this.$store.getters.language || "cn",
                type: "allChild",
                keys: [
                    "X_YX",
                    "X_PYCC",
                    "X_PYLB",
                    "X_XWLX",
                    "X_XXXS",
                    "X_RXFS",
                    "K_SQYY",
                    "X_RXJJ",
                    "K_YDSQLX"
                ]
            };
            queryDic(data).then(res => {
                if (res.code === 200) {
                    this.fill("faculty", res.data.X_YX);
                    this.fill("trainingLevel", res.data.X_PYCC);
                    this.fill("trainingCategory", res.data.X_PYLB);
                    this.fill("degreeType", res.data.X_XWLX);
                    this.fill("formLearning", res.data.X_XXXS);
                    this.fill("enrolMethods", res.data.X_RXFS);
                    this.fill("applyReason", res.data.K_SQYY);
                    this.fill("permitType", res.data.K_YDSQLX);
                    this.fill("enrolSeason", res.data.X_RXJJ);
                }
            });
            // getGraduateDegreeByColleges({}).then(res => {
            //     if (res.code == 200) {
            //         let language = this.$store.getters.language || "cn";
            //         this.options.masProfessions = res.data.map(row => {
            //             return {
            //                 label:
            //                     (language == "cn" ? row.nameCN : row.nameEn) +
            //                     " (" +
            //                     row.code +
            //                     ")",
            //                 value: row.code
            //             };
            //         });
            //     }
            // });
            getStuTeas().then(res => {
                if (res.code == 200) {
                    let teachers = [];
                    for (let key in res.data) {
                        this.options.masTeachers.push({
                            label: res.data[key] + "(" + key + ")",
                            value: key
                        });
                    }
                }
            });
            this.onSubmit();
        },
        fill(type, data) {
            for (const key in data) {
                this.options[type].push({
                    value: key,
                    label: data[key]
                });
            }
        },
        reset() {
            // this.queryForm.grade = null;
            // this.queryForm.faculty = null;
            // this.queryForm.profession = null;
            // this.queryForm.trainingLevel = null;
            // this.queryForm.trainingCategory = null;
            // this.queryForm.degreeType = null;
            // this.queryForm.formLearning = null;
            // this.queryForm.enrolMethodList = [];
            // this.queryForm.keyWord = null;
            // this.options.profession.length = 0;
            this.queryForm.grade = null;
            this.queryForm.faculty = [];
            this.queryForm.profession = [];
            this.queryForm.permitType = null;
            this.queryForm.degreeType = null;
            this.queryForm.formLearning = null;
            this.queryForm.applyReason = [];
            this.queryForm.approvalStatus = [];
            this.queryForm.applicationStartTime = null;
            this.queryForm.applicationEndTime = null;
            this.queryForm.keyWord = null;
            this.options.profession.length = 0;
            this.onSubmit();
        },
        moment(val) {
            return moment(val).format("YYYY-MM-DD HH:mm:ss");
        },
        getApproveText(scope) {
            let option = this.options.approvalStatus.find(
                s => s.value == scope.row.approvalStatus
            );
            return option ? option.label : null;
        },
        getFileName(path) {
            if (path.indexOf("/") != -1) {
                return path.substring(path.lastIndexOf("/") + 1);
            } else {
                return path;
            }
        },
        //处理下载
        handleDownLoad(file) {
            // downloadfile(file);
            let url = '/api/commonservice/obsfile/downloadfile?objectkey=' + file.url  
            stu.downTemplate(file.name, url);
        },
        //预览组内用户信息
        handleReviewGroup(groupId) {
            this.$refs.groupUsers.open();
            this.usersQueryForm.groupId = groupId;
            this.getGroupUsersByGroupId();
        },
        //关闭组内用户信息时初始化
        handleGroupUsersClose() {
            this.usersQueryForm.groupId = null;
            this.usersQueryForm.pageNum_ = 1;
            this.usersQueryForm.pageSize_ = 20;
            this.usersQueryForm.total_ = 0;
        },
        //组内用户信息翻页
        handleUserCurrentChange(val) {
            this.usersQueryForm.pageSize_ = val.pageSize;
            this.usersQueryForm.pageNum_ = val.pageNum;
            this.getGroupUsersByGroupId();
        },
        //获取组内用户列表
        getGroupUsersByGroupId(groupId) {
            getUserInfoListByGroupId({
                groupId: this.usersQueryForm.groupId,
                pageNum_: this.usersQueryForm.pageNum_,
                pageSize_: this.usersQueryForm.pageSize_,
                total: 0,
                userName: ""
            }).then(res => {
                if (res.code == 200) {
                    this.users = res.data.list;
                    this.usersQueryForm.total_ = res.data.total_;
                }
            });
        },
        getUserType(val) {
            if (val == 1) {
                return "老师";
            }
            if (val == 2) {
                return "学生";
            }
            if (val == 3) {
                return "本地用户";
            }
            return null;
        },
        handleDetail(scope) {
            this.isRead = true;
            this.historys = []
            this.currentStudent = _.cloneDeep(scope.row);
            if(scope.row.evidence && scope.row.evidence.length > 0) {
        if((scope.row.evidence.substring(0,1)).toString() === '[') {
          this.currentStudent.evidence = JSON.parse(scope.row.evidence)
        } else {
          let filesList = []
          let evidList = scope.row.evidence.split(",")
          evidList.map(files=> {
            filesList.push(
              {
                name: files,
                url: files
              }
            )
          })
          this.currentStudent.evidence = filesList
        }
       }
            this.indexKey = "2";
            this.breadPath.children[1].label = this.$t("message.detail");
            if (this.currentStudent.workflowNo) {
                approvalHistory(
                    this.currentStudent.workflowNo,
                    this.currentStudent.submissionType
                ).then(res => {
                    if (res.code == 200) {
                        res.data.forEach((row, index) => {
                            row.order_ = index + 1;
                            if (row.reasonDescri == "null") {
                                row.reasonDescri = null;
                            }
                        });
                        this.historys = res.data;
                    }
                });
            }
        },
        onSubmit(isFirstPage = true) {
            if (isFirstPage) {
                this.queryForm.pageNum_ = 1;
            }
            let params = _.cloneDeep(this.queryForm);
            params.submissionType = this.submissionType
            params.applicant = this.global.currentUser.uid
            params.faculty =
                params.faculty.length > 0 ? params.faculty.join(",") : null;
            params.profession =
                params.profession.length > 0
                    ? params.profession.join(",")
                    : null;
            params.applyReason =
                params.applyReason && params.applyReason.length > 0
                    ? params.applyReason.join(",")
                    : null;
            params.approvalStatus =
               params.approvalStatus && params.approvalStatus.length > 0
                    ? params.approvalStatus.join(",")
                    : null;
            getmanageList(params).then(res => {
                if (res.code == 200) {
                    this.students = res.data.list;
                    this.queryForm.total_ = res.data.total_;
                }
            });
        },
        getOneStu() {
            let parm = {
                pageSize_: 1,
                pageNum_: 1,
                studentId: this.searchStudentId

            }
             
            if(this.searchStudentId) {
                getRepStuAppList(parm).then(res => {
                if (res.code == 200 && res.data && res.data.list.length > 0) {
                            this.selectedStudents = res.data.list;
                            // getStudentInfo(
                            //     this.selectedStudents.map(s => s.studentId).join(",")
                            // ).then(resT => {
                            //     if(resT.code === 200) {
                            //         // this.$refs.applyForm.init();
                            //     }
                            // });
                        let parm = {
                            trainingLevel: 4,
                            facultys: [res.data.list[0].faculty],
                            types: [res.data.list[0].degreeType]
                        }
                        getGraduateDegreeByColleges(parm).then(resT => {
                        if (resT.code == 200) {
                            let language = this.$store.getters.language || "cn";
                            this.options.masProfessions = resT.data.map(row => {
                                return {
                                    label:
                                        (language == "cn" ? row.nameCN : row.nameEn) +
                                        " (" +
                                        row.code +
                                        ")",
                                    value: row.code
                                };
                            });
                        }
                    });
                    this.$refs.applyForm.applyForm.masDegreeType = res.data.list[0].degreeType;
                } else {
                    this.$message.error('未查询到学生信息')
                    this.searchStudentId = ''
                    this.options.masProfessions = []
                    this.selectedStudents = [
                        {
                            name:'',
                            facultyI18n: '',
                            professionI18n: '',
                            grade: '',
                            teacherName:'',
                            teacherId: '',
                            trainingLevelI18n: '',
                            trainingCategoryI18n: '',
                            degreeTypeI18n: '',
                            degreeType: '',
                            formLearningI18n: '',
                            enrolMethodsI18n: '',
                        }
                    ]
                }
            });
        } else {
            this.searchStudentId = ''
            this.options.masProfessions = []
            this.selectedStudents = [
                {
                    name:'',
                    facultyI18n: '',
                    professionI18n: '',
                    grade: '',
                    teacherName:'',
                    teacherId: '',
                    trainingLevelI18n: '',
                    trainingCategoryI18n: '',
                    degreeType: '',
                    degreeTypeI18n: '',
                    formLearningI18n: '',
                    enrolMethodsI18n: '',
                }
            ]
        }
        this.$refs.applyForm.applyForm.masDegreeType = '';
        this.$refs.applyForm.applyForm.masProfession = '';
        
    },
        handleAgentApply() {
            // this.selectedStudents = [student];
            // getStudentInfo(
            //     this.selectedStudents.map(s => s.studentId).join(",")
            // ).then(resT => {
            //     if(resT.code === 200) {
            //     this.$refs.applyForm.init();
            //     this.indexKey = "1";
            //     }
            // });
            this.$refs.applyForm.init();
            this.indexKey = "1";
            this.$refs.applyForm.init();
            this.options.masProfessions = []
            this.searchStudentId = ''
                    this.selectedStudents = [
                        {
                            name:'',
                            facultyI18n: '',
                            professionI18n: '',
                            grade: '',
                            teacherName:'',
                            teacherId: '',
                            trainingLevelI18n: '',
                            degreeType: '',
                            trainingCategoryI18n: '',
                            degreeTypeI18n: '',
                            formLearningI18n: '',
                            enrolMethodsI18n: '',
                        }
                    ]
        },
        handleCurrentChange(val) {
            this.queryForm.pageSize_ = val.pageSize;
            this.queryForm.pageNum_ = val.pageNum;
            this.onSubmit(false);
        },
        handleChangeFaculty() {
            this.options.profession = [];
            this.queryForm.profession = [];
            if (this.queryForm.faculty.length === 0) {
                return;
            }
            const data = {
                lang: this.$store.getters.language || "cn",
                type: "allChild",
                keys: ["G_ZY"],
                filter: {
                    prefix: this.queryForm.faculty,
                    specilaCode: "XY2ZY",
                    grade: null,
                    facultys: this.queryForm.faculty,
                    degreeType: this.queryForm.degreeType
                        ? [this.queryForm.degreeType]
                        : []
                }
            };
            queryDic(data).then(res => {
                if (res.code === 200) this.fill("profession", res.data.G_ZY);
            });
        },
        handleReturn() {
            this.indexKey = "0";
            this.onSubmit();

        },
        handleSuccess() {
            this.indexKey = "0";
            this.onSubmit();
        }
    }
};
</script>

<style lang="scss" scoped>
#stu-info {
    ::v-deep .el-form-item--small.el-form-item {
        margin-bottom: 5px;
    }
}
.table-detail {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #d2d4d6;
    td {
        border-collapse: collapse;
        border: 1px solid #d2d4d6;
        line-height: 32px;
    }
    .label {
        text-align: right;
        background: #f5f7f9;
        color: #8896a7;
    }
    span {
        margin: 0 10px;
    }
}
</style>